{include file="public/layout" /}
<body>
<div class="layui-fluid" id="LAY-component-layer-list">
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="web-system">
                    <div class="layui-tab layui-tab-card">
                        <div class="layui-tab-content" style="padding:10px 0">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-row layui-col-space15">
                                    <div class="layui-col-md12">
                                        <div class="layui-card">
                                            <div class="layui-card-body" pad15>
                                                <div class="layui-form" wid100>
                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label">问答状态</label>
                                                        <div class="layui-input-block">
                                                            <input type="checkbox" lay-filter="question_status" lay-skin="switch" lay-text="开启|关闭" {notempty name="$config.question_status"}checked{/notempty}>
                                                            <input type="hidden" name="question_status" value="{$config.question_status|default='0'}" />
                                                        </div>
                                                    </div>
                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label">登陆才可提问</label>
                                                        <div class="layui-input-inline w70">
                                                            <input type="checkbox" lay-filter="question_ask_status" lay-skin="switch" lay-text="是|否" {notempty name="$config.question_ask_status"}checked{/notempty}>
                                                            <input type="hidden" name="question_ask_status" value="{$config.question_ask_status|default='0'}" />
                                                        </div>
                                                        <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                                            <div class="layui-form-mid layui-word-aux ey_helptips"></div>
                                                            <div class="layui-form-inline2 ey_helptips_txt">必须登陆后才能提问，否则跳转到登陆窗口</div>
                                                        </div>
                                                    </div>
                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label">提问需审核</label>
                                                        <div class="layui-input-inline w70">
                                                            <input type="checkbox" lay-filter="question_ask_check" lay-skin="switch" lay-text="是|否"{notempty name="$config.question_ask_check"}checked{/notempty}>
                                                            <input type="hidden" name="question_ask_check" value="{$config.question_ask_check|default='0'}" />
                                                        </div>
                                                        <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                                            <div class="layui-form-mid layui-word-aux ey_helptips"></div>
                                                            <div class="layui-form-inline2 ey_helptips_txt">提问内容默认为待审核状态，后台审核通过后才显示在网站</div>
                                                        </div>
                                                    </div>
                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label">登陆才可回答</label>
                                                        <div class="layui-input-inline w70">
                                                            <input type="checkbox" lay-filter="question_ans_status" lay-skin="switch" lay-text="是|否" {notempty name="$config.question_ans_status"}checked{/notempty}>
                                                            <input type="hidden" name="question_ans_status" value="{$config.question_ans_status|default='0'}" />
                                                        </div>
                                                        <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                                            <div class="layui-form-mid layui-word-aux ey_helptips"></div>
                                                            <div class="layui-form-inline2 ey_helptips_txt">必须登陆后才能回答，否则跳转到登陆窗口</div>
                                                        </div>
                                                    </div>

                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label">回答需审核</label>
                                                        <div class="layui-input-inline w70">
                                                            <input type="checkbox" lay-filter="question_ans_check" lay-skin="switch" lay-text="是|否" {notempty name="$config.question_ans_check"}checked{/notempty}>
                                                            <input type="hidden" name="question_ans_check" value="{$config.question_ans_check|default='0'}" />
                                                        </div>
                                                        <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                                            <div class="layui-form-mid layui-word-aux ey_helptips"></div>
                                                            <div class="layui-form-inline2 ey_helptips_txt">回答内容默认为待审核状态，后台审核通过后才显示在网站</div>
                                                        </div>
                                                    </div>

                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label"><b>*</b>栏目标题</label>
                                                        <div class="layui-input-inline">
                                                            <input id="typename" name="typename"  lay-verify="required" value="{$arctype.typename|default=''}" class="layui-input" type="text"/>
                                                        </div>
                                                        <div class="layui-form-mid layui-word-aux ey_helptips"></div>
                                                        <div class="layui-form-inline2 ey_helptips_txt"></div>
                                                    </div>


                                                    <div class="layui-form-item">
                                                        <div class="layui-input-block">
                                                            <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">

        layui.config({
            base: '__SKIN__/' //静态资源所在路径
            ,version: '{$version}'
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form'], function(){
            var $ = layui.$
                ,layer = layui.layer
                ,form = layui.form;

            tipsText();

            /* 触发事件 */
            var active = {

            };

            $('#LAY-component-layer-list .layui-btn').on('click', function(){
                var type = $(this).data('type');
                active[type] && active[type].call(this);
            });

            // 监听开关
            form.on('switch', function(data){
                var elemId = data.elem.attributes['lay-filter']['nodeValue'];
                if (data.elem.checked) {
                    this.value = 1;
                } else {
                    this.value = 0;
                }
                $("input[name='"+elemId+"']").val(this.value);
            });

            //监听提交
            form.on('submit(formSubmit)', function(data){
                var load = layer_loading();
                data.field._ajax = 1;
                $.ajax({
                    type : 'post',
                    url : "{:url('System/question')}",
                    data : data.field,
                    dataType : 'json',
                    success : function(res){
                        layer.close(load); //关闭loading
                        if(res.code == 1){
                            layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                                window.location.reload();
                            });
                        }else{
                            showErrorMsg(res.msg);
                        }
                    },
                    error: function(e){
                        layer.close(load); //关闭loading
                        showErrorAlert();
                    }
                });
                return false;
            });

        });
    </script>

    {include file="public/footer" /}
